import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
  	isLogin: false,
      foodDetails:[],
  },
  mutations: {
  	changeLogin(state, isOK) {
  		state.isLogin = isOK;
  	},
      addDetails(state,detail){
  	    state.foodDetails[detail.foodID]=detail.details;
      },
      deleteDetails(state,foodID){
  	    state.foodDetails[foodID]=[];
      },
      deleteAllDetails(state){
  	    state.foodDetails=[];
      },
  },
  getters: {
  	getisLogin(state) {
  		return state.isLogin;
  	},
      getDetails:(state)=>(foodID)=>{
  	    if(!state.foodDetails[foodID]){
  	        return [];
        }
  	    return state.foodDetails[foodID];
      },
  },
  actions: {
  	
  },
  modules: {}
})
